package cre.jaxrs.basic.service;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import cre.jaxrs.domain.Order;

@Path("/orderService/")
@Produces({"application/xml","application/json"})  
public class OrderService {

	Map<String, Order> orders = new HashMap<String, Order>();

	public OrderService() {
		Order order = new Order();
		order.setId("1");
		order.setName("test");

		orders.put(order.getId(), order);
	}

	@GET
	@Path("/orders/{id}")
	public cre.jaxrs.domain.Order getOrder(@PathParam("id") String id) {
		System.out.println("----invoking getOrder, Order id is: " + id);

		return orders.get(id);
	}
	
	@GET
	@Path("/orderjson/")
	public String getOrder() {
		System.out.println("----invoking getOrder");

		return "test";
	}
}
